import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Test {

  /**
   * @param args
   */
  public static void main(String[] args) {

    int chunkSize = 20;
    int startIndex = 0;
    int endIndex = -1;

    int size = 47;

    for (int i = 0; i < size; i += chunkSize) {
      startIndex = i;
      endIndex = (startIndex + chunkSize < size) ? startIndex + chunkSize : size;

      if (startIndex < endIndex) {
        System.out.println(String.format("start=%s end=%s", startIndex, endIndex));
      }
    }

    Calendar cal = Calendar.getInstance();
    cal.get(Calendar.DAY_OF_WEEK);
    Date start = cal.getTime();
    cal.add(Calendar.DATE, -1);
    Date end = cal.getTime();

    System.out.println(start.toGMTString());
    System.out.println(end.toGMTString());

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat timeFormat = new SimpleDateFormat("hh:mm:ssZ");

    Date now = new Date();

    System.out.println(String.format("%sT%s", dateFormat.format(now), timeFormat.format(now)));
  }

}
